<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">搜索github用户</h3>
    <div>
      <input type="text" placeholder="请输入用户名字" v-model="keyword" />&nbsp;<button
        @click="handClick">搜索</button>
    </div>
  </section>
</template>

<script>
import axios from 'axios';
export default {
  name: 'Search',
  data() {
    return {
      keyword: '',
    };
  },
  methods: {
    handClick() {
      axios.get(`https://api.github.com/search/users?q=${this.keyword}`).then(
        (req) => {
          // console.log('请求成功', req.data);
          this.$bus.$emit('getList', req.data.items);
        },
        (err) => {
          console.log('请求失败', err);
        }
      );
    },
  },
};
</script>

<style scoped>
.album {
  min-height: 50rem;
  /* Can be removed; just added for demo purposes */
  padding-top: 3rem;
  padding-bottom: 3rem;
  background-color: #f7f7f7;
}
</style>